<!doctype html><html xmlns="http://www.w3.org/1999/xhtml" id="html">
    <head>
        <title></title>
        <meta http-equiv="content-type" content="text/html; charset=utf-8" />
        <base href="<?= base_url(1); ?>" />
        <link type="text/css" href="css/main.css?v=<?= $config['version'] ?>" rel="stylesheet" />
    </head>
    <body>
        <?php include(VIEWPATH . 'common/main_header.php'); ?>
        <?php
        	//var_dump($arealist); 
        ?>
        <form action="" method="POST" id="rowForm">
            <table width="100%" border="0" cellspacing="1" cellpadding="0" class="tablegrid tableedit">
                <tr>
                    <td><?= translate('GENERAL_CRONTAB_TITLE') ?>:</td>
                    <td><input type="text" name="row[title]" id="title" value="" /></td>
                </tr>
                <tr>
                    <td><?= translate('GENERAL_CRONTAB_TYPE') ?>:</td>
                    <td>
                        <?= $type ?>
                    </td>
                </tr>

                <tr class="hide type notice">
                    <td><?= translate('GENERAL_CRONTAB_ACCEPT_AREA') ?>:</td>
                    <td>
                        <?= $channel ?>
                    </td>
                </tr>
                <tr class="hide type notice">
                    <td><?= translate('GENERAL_CRONTAB_ACCEPT_PLAYER') ?>:</td>
                    <td><input type="text" name="row[content][receiver_id]" id="receiver_id" value="0" /></td>
                </tr>
                <tr class="hide type notice">
                    <td><?= translate('GENERAL_CRONTAB_MSG') ?>:</td>
                    <td><textarea name="row[content][msg]" id="msg" cols="50" rows="5"></textarea></td>
                </tr>

                <tr class="hide type module">
                    <td><?= translate('GENERAL_CRONTAB_MODNAME') ?>:</td>
                    <td><input type="text" name="row[content][module]" id="module" value="" /></td>
                </tr>

                <tr class="hide type module">
                    <td><?= translate('GENERAL_CRONTAB_ACTNAME') ?>:</td>
                    <td><input type="text" name="row[content][method]" id="method" value="index" /></td>
                </tr>

                <tr class="hide type url">
                    <td><?= translate('GENERAL_CRONTAB_ASK_URL') ?>:</td>
                    <td><input type="text" name="row[content][url]" id="url" value="" style="width:250px;" /></td>
                </tr>

                <tr class="hide type group_mail">
                    <td><?= translate('GENERAL_CRONTAB_GROUP_MAIL_ID') ?>:</td>
                    <td>
                    <!--
                    <input type="text" name="row[content][group_mail_id]" id="group_mail_id" value="" style="width:50px;" />
                    -->
                    <select  name="row[content][group_mail_id]" id="group_mail_id" >
                    		<?php foreach ($maillist as $key => $value) { ?>
							<option value="<?=$key ?>"><?=$key."-".$value ?></option>					
							<?php } ?>		
           	      	</select>
                    </td>
                </tr>
                <tr>
                    <td><?= translate('GENERAL_CRONTAB_EXCUTE_TIMES') ?>:</td>
                    <td>
                        <?= $frequence ?>
                    </td>
                </tr>

                <tr class="hide frequence repeat">
                    <td><?= translate('GENERAL_CRONTAB_MAX_EXCUTE_TIMES') ?>:</td>
                    <td><input type="text" name="row[maximums]" id="maximums" value="0"/></td>
                </tr>

                <tr class="hide frequence repeat">
                    <td><?= translate('RUNTIME') ?>:</td>
                    <td>
                        <span><input type="text" name="row[content][crontime][minute]" id="cronminute" class="crontime" placeholder="0-59" size="3" /> (<?= translate('MINUTE') ?>)</span>
                        <span><input type="text" name="row[content][crontime][hour]" id="cronhour" class="crontime" placeholder="0-23" size="3" /> (<?= translate('HOUR') ?>)</span>
                        <span><input type="text" name="row[content][crontime][day]" id="cronday" class="crontime" placeholder="1-31" size="3" /> (<?= translate('DAY') ?>)</span>
                        <span><input type="text" name="row[content][crontime][month]" id="cronmonth" class="crontime" placeholder="1-12" size="3" /> (<?= translate('MONTH') ?>)</span>
                        <span><input type="text" name="row[content][crontime][week]" id="cronweek" class="crontime" placeholder="0-6" size="2" /> (<?= translate('WEEK') ?>)</span>
                        <a href="javascript:;" class="help" module="cron"><?= translate('README') ?></a>
                        <span id="cron_id"></span>
                    </td>
                </tr>

                <tr>
                    <td><?= translate('STARTTIME') ?>:</td>
                    <td><input type="text" name="row[starttime]" id="starttime" value="<?= date("Y-m-d H:i:s") ?>" 
                    class="datepicker" showtime="true" size=25px/></td>
                </tr>
                <tr class="hide frequence repeat">
                    <td><?= translate('EXPIRETIME') ?>:</td>
                    <td><input type="text" name="row[expiretime]" id="expiretime" value="0" class="datepicker" showtime="true" size=25px/></td>
                </tr>
                <tr>
                    <td><?= translate('SYNC') ?>:</td>
                    <td><?= $arealist ?></td>
                </tr>
                <tr>
                    <tr><td></td>
                        <td>
                            <input type="submit" value="<?= translate('SUBMIT') ?>" id="submit"/> <input type="reset" value="<?= translate('RESET') ?>" id="reset"/>
                        </td>
                    </tr>
            </table>
        </form>
        <script type="text/javascript">
            $(function() {
                SG.init("core.form", function() {
                    $.formValidator.initConfig({formid: "#rowForm", submitonce: true});
                    $("#type").formValidator({empty: false, onshow: '<?= translate('C_NOT_EMPTY') ?>'});
                    $("#title").formValidator({empty: false, onshow: '<?= translate('C_NOT_EMPTY') ?>'}).inputValidator({min: 1, onerrormin: '<?= translate('C_NOT_EMPTY') ?>'});
                    $("#maximums").formValidator({empty: true, onshow: '<?= translate('GENERAL_CRONTAB_VALID_MAXIMUMS') ?>'});
                    $("#executetime").formValidator({empty: false, onshow: '<?= translate('C_NOT_EMPTY') ?>'}).inputValidator({min: 1, onerrormin: '<?= translate('C_NOT_EMPTY') ?>'});
                    $("#starttime").formValidator({empty: false, onshow: '<?= translate('C_NOT_EMPTY') ?>'});
                    $("#expiretime").formValidator({empty: false, onshow: '<?= translate('EXPIRETIME') ?>'});

                    $("#module").formValidator({empty: false, onshow: '<?= translate('C_NOT_EMPTY') ?>'}).inputValidator({min: 1, onerrormin: '<?= translate('C_NOT_EMPTY') ?>'});
                    $("#method").formValidator({empty: false, onshow: '<?= translate('C_NOT_EMPTY') ?>'}).inputValidator({min: 1, onerrormin: '<?= translate('C_NOT_EMPTY') ?>'});

                    $("#url").formValidator({empty: false, onshow: '<?= translate('GENERAL_CRONTAB_VALID_URL') ?>'}).inputValidator({min: 1, onerrormin: '<?= translate('C_NOT_EMPTY') ?>'});

                    $("#receiver_id").formValidator({empty: false, onshow: '<?= translate('GENERAL_CRONTAB_VALID_PLAYER') ?>'}).regexValidator({regexp: 'num', datatype: 'enum', onerror: '<?= translate('C_ONLY_NUM') ?>'});
                    $("#msg").formValidator({empty: false, onshow: '<?= translate('C_NOT_EMPTY') ?>'}).inputValidator({min: 1, onerrormin: '<?= translate('C_NOT_EMPTY') ?>'});
                    $(".crontime").formValidator({empty: false, onshow: ''}).inputValidator({min: 1, onerrormin: '<?= translate('C_NOT_EMPTY') ?>'});
                    
                    $("#group_mail_id").formValidator({empty: false, onshow: '<?= translate('C_ONLY_NUM') ?>'}).regexValidator({regexp: 'num', datatype: 'enum', onerror: '<?= translate('C_ONLY_NUM') ?>'});
                    $("#type").change();
                    $("#frequence").change();
                });
                $("#type,#frequence").change(function() {
                    var type = $(this).attr("id");
                    var val = $(this).val();
                    $("tr." + type).hide();
                    $("." + val).show();
                    $("tr." + type + " td input,tr." + type + " td textarea").unFormValidator(true);
                    $("tr." + val + " td input,tr." + val + " td textarea").unFormValidator(false);
                });
            });
        </script>
    </body>
</html>